
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 01/25/2013 09:52:49
-- Generated from EDMX file: C:\Users\User\documents\visual studio 2010\Projects\MvcApplication1\MvcApplication1\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [aspnet-MvcApplication1-20130123172451];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------


-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'UsersНабор'
CREATE TABLE [dbo].[UsersНабор] (
    [Id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [login] nvarchar(max)  NOT NULL,
    [password] nvarchar(max)  NOT NULL,
    [name] nvarchar(max)  NOT NULL,
    [surname] nvarchar(max)  NOT NULL,
    [email] nvarchar(max)  NOT NULL,
    [region] nvarchar(max)  NOT NULL,
    [status] nvarchar(max)  NOT NULL,
    [role] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'ItemsНабор'
CREATE TABLE [dbo].[ItemsНабор] (
    [Id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [description] nvarchar(max)  NOT NULL,
    [name] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'OrdersНабор'
CREATE TABLE [dbo].[OrdersНабор] (
    [Id] int PRIMARY KEY IDENTITY(1,1) NOT NULL ,
    [id_customer] nvarchar(max)  NOT NULL,
    [id_merchendaiser] nvarchar(max)  NOT NULL,
    [date] nvarchar(max)  NOT NULL,
    [status] nvarchar(max)  NOT NULL,
    [id_card] nvarchar(max)  NOT NULL,
    [gift] nvarchar(max)  NOT NULL,
    [Users_Id] int  NOT NULL
);
GO

-- Creating table 'ItemsofordersНабор'
CREATE TABLE [dbo].[ItemsofordersНабор] (
    [Id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [id_order] nvarchar(max)  NOT NULL,
    [id_shipmentcost] nvarchar(max)  NOT NULL,
    [quantity] nvarchar(max)  NOT NULL,
    [Orders_Id] int  NOT NULL,
    [shipmentscost_id] int  NOT NULL
);
GO

-- Creating table 'shipmentsНабор'
CREATE TABLE [dbo].[shipmentsНабор] (
    [id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [id_items] nvarchar(max)  NOT NULL,
    [id_packages] nvarchar(max)  NOT NULL,
    [quantity] nvarchar(max)  NOT NULL,
    [remain] nvarchar(max)  NOT NULL,
    [date] nvarchar(max)  NOT NULL,
    [desription] nvarchar(max)  NOT NULL,
    [status] nvarchar(max)  NOT NULL,
    [Items_Id] int  NOT NULL,
    [packages_id] int  NOT NULL
);
GO

-- Creating table 'shipmentscostНабор'
CREATE TABLE [dbo].[shipmentscostНабор] (
    [id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [id_shipment] nvarchar(max)  NOT NULL,
    [date] nvarchar(max)  NOT NULL,
    [cost] nvarchar(max)  NOT NULL,
    [shipment_id] int  NOT NULL
);
GO

-- Creating table 'cardsНабор'
CREATE TABLE [dbo].[cardsНабор] (
    [id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [id_customer] nvarchar(max)  NOT NULL,
    [cardtype] nvarchar(max)  NOT NULL,
    [Users_Id] int  NOT NULL
);
GO

-- Creating table 'cardsattributesvaluesНабор'
CREATE TABLE [dbo].[cardsattributesvaluesНабор] (
    [id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [id_card] nvarchar(max)  NOT NULL,
    [id_cardattributes] nvarchar(max)  NOT NULL,
    [value] nvarchar(max)  NOT NULL,
    [cards_id] int  NOT NULL,
    [cardsattributes_id] int  NOT NULL
);
GO

-- Creating table 'cardsattributesНабор'
CREATE TABLE [dbo].[cardsattributesНабор] (
    [id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [name] nvarchar(max)  NOT NULL,
    [typetoconvert] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'packagesНабор'
CREATE TABLE [dbo].[packagesНабор] (
    [id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,
    [name] nvarchar(max)  NOT NULL,
    [description] nvarchar(max)  NOT NULL,
    [capacity] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'UsersНабор'
ALTER TABLE [dbo].[UsersНабор]
ADD CONSTRAINT [PK_UsersНабор]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ItemsНабор'
ALTER TABLE [dbo].[ItemsНабор]
ADD CONSTRAINT [PK_ItemsНабор]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OrdersНабор'
ALTER TABLE [dbo].[OrdersНабор]
ADD CONSTRAINT [PK_OrdersНабор]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ItemsofordersНабор'
ALTER TABLE [dbo].[ItemsofordersНабор]
ADD CONSTRAINT [PK_ItemsofordersНабор]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [id] in table 'shipmentsНабор'
ALTER TABLE [dbo].[shipmentsНабор]
ADD CONSTRAINT [PK_shipmentsНабор]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'shipmentscostНабор'
ALTER TABLE [dbo].[shipmentscostНабор]
ADD CONSTRAINT [PK_shipmentscostНабор]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'cardsНабор'
ALTER TABLE [dbo].[cardsНабор]
ADD CONSTRAINT [PK_cardsНабор]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'cardsattributesvaluesНабор'
ALTER TABLE [dbo].[cardsattributesvaluesНабор]
ADD CONSTRAINT [PK_cardsattributesvaluesНабор]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'cardsattributesНабор'
ALTER TABLE [dbo].[cardsattributesНабор]
ADD CONSTRAINT [PK_cardsattributesНабор]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'packagesНабор'
ALTER TABLE [dbo].[packagesНабор]
ADD CONSTRAINT [PK_packagesНабор]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Users_Id] in table 'OrdersНабор'
ALTER TABLE [dbo].[OrdersНабор]
ADD CONSTRAINT [FK_UsersOrders]
    FOREIGN KEY ([Users_Id])
    REFERENCES [dbo].[UsersНабор]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UsersOrders'
CREATE INDEX [IX_FK_UsersOrders]
ON [dbo].[OrdersНабор]
    ([Users_Id]);
GO

-- Creating foreign key on [Users_Id] in table 'cardsНабор'
ALTER TABLE [dbo].[cardsНабор]
ADD CONSTRAINT [FK_Userscards]
    FOREIGN KEY ([Users_Id])
    REFERENCES [dbo].[UsersНабор]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Userscards'
CREATE INDEX [IX_FK_Userscards]
ON [dbo].[cardsНабор]
    ([Users_Id]);
GO

-- Creating foreign key on [Orders_Id] in table 'ItemsofordersНабор'
ALTER TABLE [dbo].[ItemsofordersНабор]
ADD CONSTRAINT [FK_OrdersItemsoforders]
    FOREIGN KEY ([Orders_Id])
    REFERENCES [dbo].[OrdersНабор]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrdersItemsoforders'
CREATE INDEX [IX_FK_OrdersItemsoforders]
ON [dbo].[ItemsofordersНабор]
    ([Orders_Id]);
GO

-- Creating foreign key on [shipmentscost_id] in table 'ItemsofordersНабор'
ALTER TABLE [dbo].[ItemsofordersНабор]
ADD CONSTRAINT [FK_shipmentscostItemsoforders]
    FOREIGN KEY ([shipmentscost_id])
    REFERENCES [dbo].[shipmentscostНабор]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_shipmentscostItemsoforders'
CREATE INDEX [IX_FK_shipmentscostItemsoforders]
ON [dbo].[ItemsofordersНабор]
    ([shipmentscost_id]);
GO

-- Creating foreign key on [shipment_id] in table 'shipmentscostНабор'
ALTER TABLE [dbo].[shipmentscostНабор]
ADD CONSTRAINT [FK_shipmentshipmentscost]
    FOREIGN KEY ([shipment_id])
    REFERENCES [dbo].[shipmentsНабор]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_shipmentshipmentscost'
CREATE INDEX [IX_FK_shipmentshipmentscost]
ON [dbo].[shipmentscostНабор]
    ([shipment_id]);
GO

-- Creating foreign key on [Items_Id] in table 'shipmentsНабор'
ALTER TABLE [dbo].[shipmentsНабор]
ADD CONSTRAINT [FK_Itemsshipments]
    FOREIGN KEY ([Items_Id])
    REFERENCES [dbo].[ItemsНабор]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Itemsshipments'
CREATE INDEX [IX_FK_Itemsshipments]
ON [dbo].[shipmentsНабор]
    ([Items_Id]);
GO

-- Creating foreign key on [packages_id] in table 'shipmentsНабор'
ALTER TABLE [dbo].[shipmentsНабор]
ADD CONSTRAINT [FK_packagesshipments]
    FOREIGN KEY ([packages_id])
    REFERENCES [dbo].[packagesНабор]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_packagesshipments'
CREATE INDEX [IX_FK_packagesshipments]
ON [dbo].[shipmentsНабор]
    ([packages_id]);
GO

-- Creating foreign key on [cards_id] in table 'cardsattributesvaluesНабор'
ALTER TABLE [dbo].[cardsattributesvaluesНабор]
ADD CONSTRAINT [FK_cardscardsattributesvalues]
    FOREIGN KEY ([cards_id])
    REFERENCES [dbo].[cardsНабор]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_cardscardsattributesvalues'
CREATE INDEX [IX_FK_cardscardsattributesvalues]
ON [dbo].[cardsattributesvaluesНабор]
    ([cards_id]);
GO

-- Creating foreign key on [cardsattributes_id] in table 'cardsattributesvaluesНабор'
ALTER TABLE [dbo].[cardsattributesvaluesНабор]
ADD CONSTRAINT [FK_cardsattributescardsattributesvalues]
    FOREIGN KEY ([cardsattributes_id])
    REFERENCES [dbo].[cardsattributesНабор]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_cardsattributescardsattributesvalues'
CREATE INDEX [IX_FK_cardsattributescardsattributesvalues]
ON [dbo].[cardsattributesvaluesНабор]
    ([cardsattributes_id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------